var cp = require('child_process'),
    psTree = require('ps-tree');

console.log("------ current process id: ", process.pid)
console.log("------ here")
var child = cp.exec("node -e 'while (true);'", function () { /*...*/ });
console.log("child process pid: ", child.pid)

console.log("-------- 2")
psTree(process.pid, function (err, children) {
  console.log("------- 3")
  children.forEach(function(ele) {
    console.log(ele);
  });
  console.log("------ 4")
  cp.spawn('kill', ['-9'].concat(children.map(function (p) { return p.PID })));
  console.log("------ 5")
});
